

$(function () {
	
	/*修复编辑器在超长长度下头部菜单上漂的bug  */
	(function(){
		setInterval(function(){
			$(window).resize();
		},1000);
	})();
	
	
    $(window).load(function () {
        $("#left_menu").mCustomScrollbar({
            scrollButtons: {
                enable: true,
                theme: "dark"
            }
        });

    });

    /*左边折叠菜单*/
    $('.page_menu_left>li>a').unbind('click');
    $('.page_menu_left>li>a').on('click', function () {
        if ($(this).closest('li').hasClass('open'))
        {
            $(this).next().slideUp(200);
            $(this).closest('li').removeClass('open');
            return false;
        }
        else
        {
            $(this).closest('li').siblings().each(function () {
                $(this).find('ul.sub_menu').slideUp(200);
                $(this).removeClass('open');
            });
            $(this).next().slideDown(200).closest('li').addClass('open');
            return false;
        }
    });


    $('#message_wraper').on('close.bs.alert', function () {
        $(this).fadeOut();
        return false;
    });

    $('#message_w_alert').on('close.bs.alert', function () {
        $(this).fadeOut();
        return false;
    });

});

function ajax_go(data, url, reload)
{
    swal('正在提交，请稍后....');
    $.ajax({
        url: url,
        type: "POST",
        data: data,
        cache: false
    }).done(function (msg) {
        if (msg.result === 1) {
            swal('操作成功', '', 'success');

            if (reload)
            {
                window.location.reload();
            }
            $('#myModal').modal("hide");
            return 1;
        }
        else {
            swal('操作失败：' + msg.desc, '', 'error');
            return 0;
        }

    }).error(function (ex) {
        swal('操作错误', '', 'error');
        return 0;
    });

}
function ajax_go_1(data, url, call_back_func)
{
    xw_loader.start();
    $.ajax({
        url: url,
        type: "POST",
        data: data,
        cache: false
    }).done(function (msg) {
        xw_loader.end();
        call_back_func(msg);

    }).error(function (ex) {
        xw_loader.end();
        swal('操作错误', '', 'error');
        return 0;
    });

}

var xw_loader = {
    end: function () {
        $('#xw_loader').remove();
    },
    start: function () {
        if (img_url != undefined)
            $('body').append(' <div id="xw_loader" style=""><img src="' + img_url + '/xw_loader.gif" alt=""/></div>');
    }
};

